#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2020/8/5 2:19 下午
# @Author  : wancheng.b
# @File    : locust_test.py
# @Software: PyCharm
import os

from locust import TaskSet, task, User, between


class TaskTest(TaskSet):
    wait_time = between(1, 3)

    def on_start(self):
        print('TaskSet TaskTest on_start')

    @task(1)
    def task_test(self):
        print('task_test')

    @task(3)
    def task_test1(self):
        print('test_test1')


class TestUser(User):
    wait_time = between(5, 6)
    tasks = {TaskTest: 1}

    def on_start(self):
        '''
        web端设置几个用户就执行几次
        :return:
        '''
        print('TestUser on_start')


if __name__ == '__main__':
    os.system('locust -f locust_test.py --host=https://www.baidu.com')
